import { BasicColumn, FormSchema } from '/@/components/Table';
import { userRemarkFormItem, userStatusFormItem } from '@/settings/ShareFormItem';
import { defaultRule } from '@/utils/common/validator';
import { userRemarksColumn, userStatusColumn } from '@/settings/ShareTableColumns';

const typeOptions = [
  {
    label: '收入',
    value: 0,
  },
  {
    label: '支出',
    value: 1,
  },
];
export const useIetCategoryUpdateSchemaForm = (): FormSchema[] => {
  return [
    { field: 'name', label: '类别名称', component: 'Input', rules: defaultRule() },
    {
      field: 'type',
      label: '收支类型',
      component: 'Select',
      componentProps: { options: typeOptions },
      required: true,
    },
    {
      field: 'sort',
      label: '类别排序',
      component: 'InputNumber',
      defaultValue: 0,
      componentProps: { min: 0, max: 10000 },
    },

    userStatusFormItem(),
    userRemarkFormItem(),
    { field: 'id', label: '收支类别ID', component: 'Input', show: false },
  ];
};

export const useIetCategoryListColumns = (): BasicColumn[] => {
  return [
    { title: '类别ID', dataIndex: 'id', ifShow: false },
    { title: '类别名称', dataIndex: 'name' },
    { title: '收支类型', dataIndex: 'typeStr' },
    { title: '类别排序', dataIndex: 'sort' },
    userStatusColumn(),
    userRemarksColumn(),
  ];
};

export const useIetCategoryListSearchForm = (): FormSchema[] => {
  return [
    { field: 'name', label: '收支名称', component: 'Input' },
    {
      field: 'type',
      label: '收支类型',
      component: 'Select',
      componentProps: { options: typeOptions },
    },
  ];
};
